package apiday01.object;

/**
 * object中的equals()方法内部依旧为地址的比较，一般重写
 */

public class EqualsDemo {
    public static void main(String[] args) {
        Point p1 = new Point(100,200);
        Point p2 = new Point(100,200);
        System.out.println(p1==p2);
        System.out.println(p1.equals(p2));
        System.out.println("------------------------");

        String s1 = new String("hello");
        String s2 = new String("hello");
        System.out.println(s1.equals(s2));//true,String重写了equals

        StringBuilder builder1 = new StringBuilder("hello");
        StringBuilder builder2 = new StringBuilder("hello");
        System.out.println(builder1.equals(builder2));//false，StringBuilder没重写equals
        System.out.println(s1.equals(builder1));//s1与builder1类型不同，不会相同

    }
}
